﻿using JZ.JiangSu.Model.Entity;
using System;
using System.Collections.Generic;

namespace JZ.JiangSu.IApplication.IServices
{
    public interface IApplicationService<T> where T : BaseEntity
    {
        /// <summary>
        /// 添加一个记录
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        int Add(T entity);
        /// <summary>
        /// 删除一个记录
        /// </summary>
        /// <param name="id">该记录的主键Id</param>
        /// <returns></returns>
        int Delete(int id);
        /// <summary>
        /// 删除一多个记录
        /// </summary>
        /// <param name="idList">多个记录的主键Id的集合</param>
        /// <returns></returns>
        int Delete(IList<int> idList);
        /// <summary>
        /// 更新一条记录
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        int Update(T entity);
        /// <summary>
        /// 更新一个记录的N个字段的值
        /// </summary>
        /// <param name="entityId">该记录的主键Id</param>
        /// <param name="modifyFields">要更新字段的字段名与结果值的字典集合</param>
        /// <returns></returns>
        int Update(int entityId, Dictionary<string, object> modifyFields);
        /// <summary>
        /// 更新N个记录的M个字段值
        /// </summary>
        /// <param name="entityIdList">多个记录的主键Id的集合</param>
        /// <param name="modifyFields">要更新字段的字段名与结果值的字典集合</param>
        /// <returns></returns>
        int Update(IList<int> entityIdList, Dictionary<string, object> modifyFields);
        /// <summary>
        /// 获取一条记录
        /// </summary>
        /// <param name="entityId">该记录的主键Id</param>
        /// <returns></returns>
        T GetEntityById(int entityId);
        /// <summary>
        /// 获取表中所有记录
        /// </summary>
        /// <returns></returns>
        List<T> GetAllEntities();
        /// <summary>
        /// 通过Id获取多条记录
        /// </summary>
        /// <param name="idList">多个记录的主键Id的集合</param>
        /// <returns></returns>
        List<T> GetEntitiesByIds(IList<int> idList);
    }
}
